package cn.qn.service.impl.sys;

import cn.qn.moudle.sys.Province;
import cn.qn.repository.sys.ProvinceRepository;
import cn.qn.service.sys.ProvinceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

@com.alibaba.dubbo.config.annotation.Service(interfaceClass = ProvinceService.class)
@Service
public class ProvinceServiceImpl implements ProvinceService {

    @Autowired
    private ProvinceRepository provinceRepository;

    @Override
    @Cacheable(value = "provinceAll",key = "T(String).valueOf('provinceAll')")
    public List<Province> list() {
        return provinceRepository.findAll();
    }

    @Override
    @Cacheable(value = "findProvinceByCode",key = "T(String).valueOf('findProvinceByCode').concat(#provinceCode)")
    public Province findProvinceByCode(String provinceCode){
        return provinceRepository.getOne(provinceCode);
    }

    @Override
    public Province findProvinceByName(String provinceName) {
        return provinceRepository.findByNameContaining(provinceName);
    }
}
